<template>
  <div class="container">
    <div class="bgfff">
      <div class="wrap">
        <div class="info">
          <div class="avatar">
            <img :src="info.avatar" alt="" />
          </div>
          <div class="content">
            <div class="title">
              <div class="name">
                {{ info.nickname }}
                <span v-if="info.allow_user == 1 && info.switch == 0">审核中</span>
                <span class="success" v-if="info.allow_user == 1 && info.switch == 1">审核成功</span>
                <!-- <span>审核失败</span> -->
              </div>
              <router-link
                :to="{
                  path: '/addVip',
                  query: { member_sn: member_sn },
                }"
              >
                <div class="edit" v-if="info.allow_user == 1">编辑会员资料</div>
              </router-link>
            </div>
            <div class="tag">
              <span v-for="item in info.profile" :key="item">{{ item }}</span>
            </div>
            <div class="id">
              ID:{{ info.member_sn }} <span>|</span> IP属地: {{ info.address }}
            </div>
            <div class="swiper-container mySwiper">
              <div class="swiper-wrapper">
                <div
                  class="swiper-slide"
                  v-for="item in info.photo"
                  :key="item"
                >
                  <img
                    @click="handlePictureCardPreview(item)"
                    :src="item"
                    alt=""
                  />
                </div>
              </div>
              <div class="swiper-button-next"></div>
              <div class="swiper-button-prev"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="wrap">
      <div class="row">
        <div class="col">
          <div class="title">
            <img src="@/assets/detail-icon1.png" alt="" /> 内心独白
          </div>
          <div class="content soliloquy">
            {{ info.extend.soliloquy || "未填写" }}
          </div>
        </div>
        <div class="col">
          <div class="title">
            <img src="@/assets/detail-icon2.png" alt="" />个人资料
          </div>
          <div class="content profile">
            <p>
              <span v-for="item in info.profile" :key="item">{{ item }}</span>
            </p>
            <p>
              <span
                class="extend"
                v-for="item in info.profile_extend"
                :key="item"
              >
                {{ item }}
              </span>
            </p>
          </div>
        </div>
        <div class="col">
          <div class="title">
            <img src="@/assets/detail-icon3.png" alt="" />兴趣爱好
          </div>
          <div class="content hobbies">
            <p>
              喜欢的一道菜：
              {{ info.extend.hobbies.dish || "未填写" }}
            </p>
            <p>喜欢的一本书：{{ info.extend.hobbies.book || "未填写" }}</p>
            <p>
              欣赏的一个名人：{{ info.extend.hobbies.celebrity || "未填写" }}
            </p>
            <p>喜欢做的事：{{ info.extend.hobbies.something || "未填写" }}</p>
            <p>喜欢的一首歌：{{ info.extend.hobbies.song || "未填写" }}</p>
          </div>
        </div>
        <div class="col">
          <div class="title">
            <img src="@/assets/detail-icon4.png" alt="" />择偶条件
          </div>
          <div class="content choose">
            <span v-for="item in info.choose" :key="item">{{ item }}</span>
          </div>
        </div>
      </div>
    </div>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="" />
    </el-dialog>
  </div>
</template>

<script>
import Swiper from "swiper"; // 注意引入的是Swiper
import "swiper/css/swiper.min.css"; // 注意这里的引入
export default {
  name: "IndexView",
  data() {
    return {
      member_sn: "",
      info: { extend: { hobbies: {} } },
      dialogImageUrl: "",
      dialogVisible: false,
    };
  },
  mounted() {
    this.member_sn = this.$route.query.member_sn;
    this.getInfo();
  },
  methods: {
    getInfo() {
      this.$post("user/member_detail", { member_sn: this.member_sn }).then(
        (res) => {
          this.info = res.data;
          this.getSwiper();
        }
      );
    },
    getSwiper() {
      this.swiper = new Swiper(".mySwiper", {
        slidesPerView: 4,
        spaceBetween: 10,
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
        watchSlidesVisibility: true, //防止不可点击
        // 窗口变化,重新init,针对F11全屏和放大缩小,必须加
        observer: true,
        observeParents: true,
      });
    },
    handlePictureCardPreview(url) {
      this.dialogImageUrl = url;
      this.dialogVisible = true;
    },
  },
};
</script>

<style scoped lang="scss">
.bgfff {
  background: #fff;
}
.info {
  padding: 45px 0;
  display: flex;
  align-items: center;
  .avatar {
    width: 326px;
    height: 326px;
    img {
      object-fit: cover;
      height: 100%;
    }
  }
  .content {
    width: calc(100% - 326px);
    padding-left: 24px;
  }
  .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    .name {
      font-size: 36px;
      display: flex;
      align-items: center;
      span {
        display: block;
        line-height: 24px;
        background: rgba(255, 160, 60, 0.13);
        border-radius: 12px;
        border: 1px solid #ffa03c;
        color: #ffa03c;
        opacity: 0.7;
        font-size: 12px;
        padding: 0 10px;
        margin-left: 15px;
      }

      .success {
        color: #1bbe7b;
        border: 1px solid #17bf7a;
        background: rgba(26, 194, 126, 0.13);
      }
    }
    .edit {
      color: #888888;
      font-size: 12px;
      line-height: 26px;
      border-radius: 13px;
      border: 1px solid #cccccc;
      padding: 0 15px;
    }
  }
  .tag {
    span {
      display: inline-block;
      font-size: 14px;
      line-height: 20px;
      color: #f43c8a;
      border: 1px solid #f43c8a;
      padding: 0 8px;
      margin-right: 8px;
      margin-bottom: 8px;
    }
  }
  .id {
    color: #666;
    font-size: 14px;
    padding: 20px 0;
    span {
      display: inline-block;
      padding: 0 10px;
    }
  }
}
.row {
  padding: 20px 0;
  .col {
    background: #fff;
    margin-bottom: 10px;
    .title {
      border-bottom: 1px solid #ebebeb;
      line-height: 70px;
      display: flex;
      align-items: center;
      padding: 0 24px;
      font-size: 20px;
      img {
        display: block;
        width: 24px;
        height: 24px;
        margin-right: 10px;
      }
    }
    .content {
      padding: 30px 24px;
    }
  }
}
.soliloquy {
  font-size: 14px;
  color: #666;
}
.profile {
  p {
    padding: 4px 0;
  }
  span {
    display: inline-block;
    font-size: 14px;
    line-height: 27px;
    border-radius: 100px;
    color: #f43c8a;
    background: #fcf2f6;
    padding: 0 24px;
    margin: 6px;
  }
  .extend {
    color: #595eca;
    background: #eaebff;
  }
}
.hobbies {
  display: flex;
  flex-wrap: wrap;
  p {
    width: 50%;
    padding: 10px 0;
  }
}
.choose {
  span {
    display: inline-block;
    font-size: 14px;
    line-height: 27px;
    border-radius: 100px;
    background: #f2f2f2;
    padding: 0 24px;
    margin: 6px;
  }
}
:deep .swiper-button-next,
:deep .swiper-button-prev {
  position: absolute;
  top: 50%;
  margin-top: 0;
  color: #fff;
  width: 22px;
  height: 46px;
  background: rgba($color: #000000, $alpha: 0.5);
  transform: translateY(-50%);
  cursor: pointer;
  &:after {
    font-size: 14px;
  }
}
@media screen and (max-width: 768px) {
  .info {
    padding: 25px 0;
    display: block;
    .avatar {
      width: 130px;
      height: 130px;
    }
    .content {
      width: 100%;
      padding-left: 14px;
      margin-top: 16px;
    }
    .title {
      // display: flex;
      // flex-direction: column;
      // align-items: flex-start;
      // justify-content: space-between;
      margin-bottom: 10px;
      .name {
        font-size: 20px;
        max-width: calc(100% - 120px);
      }
    }
    .tag {
      span {
        font-size: 12px;
      }
    }
    .id {
      color: #666;
      font-size: 14px;
      padding: 14px 0;
      span {
        display: inline-block;
        padding: 0 10px;
      }
    }
  }
  :deep .el-dialog {
    width: 90%;
  }
  .row .col .title {
    line-height: 50px;
    padding: 0 18px;
    font-size: 16px;
    img {
      width: 18px;
      height: 18px;
    }
  }
  .row .col .content {
    padding: 16px;
  }
  .profile span {
    font-size: 12px;
    line-height: 26px;
    padding: 0 10px;
    margin: 5px;
  }
  .row .col .content {
    padding: 14px;
  }
  .hobbies p {
    width: 100%;
    padding: 8px 0;
  }
  .choose {
    span {
      font-size: 12px;
      line-height: 26px;
      padding: 0 10px;
      margin: 5px;
    }
  }
}
</style>
